﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Ncqrs.Commanding.CommandExecution.Mapping.Attributes;
using Ncqrs.Commanding;

namespace Domain.Commands
{
    [MapsToAggregateRootConstructor(typeof(Note))] //This will send the properties to a ctor of Note that takes in same parameters
    public class CreateNoteCommand : DomainCommand
    {
        [HiddenInput(DisplayValue = false)]
        public Guid NoteId { get; set; }
        [Required]
        public string Text { get; set; }
        public int Importance { get; set; }
    }

    [MapsToAggregateRootMethod(typeof(Note), "ChangeImportance")] //This will call the ChangeImportance method on the Note with NoteId equal to NoteId and pass in the other properties (in this case, Importance)
    public class ChangeImportanceCommand : DomainCommand
    {
        [HiddenInput(DisplayValue = false)]
        [AggregateRootId]
        public Guid NoteId { get; set; }
        public int Importance { get; set; }
    }

    [MetadataType(typeof(DomainCommandMetadata))] //Base class for commands. Just has a buddy class so that the CommandIdentifier in CommandBase is not scaffolded.
    public class DomainCommand : CommandBase
    {
        public class DomainCommandMetadata
        {
            [ScaffoldColumn(false)]
            public object CommandIdentifier;
        }
    }
}
